﻿using SRB.Tg.Common;
using SRB.Tg.DrawingStandard;
using SRB.Tg.Operate;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using Teigha.DatabaseServices;
using Teigha.Geometry;

namespace SRB.Tg.Model
{
    public class AbutmentStructure
    {

        //PlinthParameter plinthParameter;
    
        System.Data.DataTable dtProject = new System.Data.DataTable();
        System.Data.DataTable dtBridge = new System.Data.DataTable();
        System.Data.DataTable dtBridgeDrawing = new System.Data.DataTable();
        System.Data.DataTable dtProjectConfig = new System.Data.DataTable();

        string _bridgeMainId = null;
        DrawingConfigModel drawingConfigModel = new DrawingConfigModel();
        string _bridgeId = "";
        string baseType = "2";

        System.Data.DataTable dtAbutment = new System.Data.DataTable();
        System.Data.DataTable dtAbutmentBackWall = new System.Data.DataTable();
        System.Data.DataTable dtAbutmentBody = new System.Data.DataTable();
        System.Data.DataTable dtAbutmentCap = new System.Data.DataTable();
        System.Data.DataTable dtAbutmentEarWall = new System.Data.DataTable();
        System.Data.DataTable dtAbutmentLadder = new System.Data.DataTable();
        System.Data.DataTable dtCushionStone = new System.Data.DataTable();
        System.Data.DataTable dtPileCap = new System.Data.DataTable();
        System.Data.DataTable dtPile = new System.Data.DataTable();
        System.Data.DataTable dtSpreadFoundation= new System.Data.DataTable();

        System.Data.DataTable dtAviationBridge = new System.Data.DataTable();
        System.Data.DataTable dtAviationBridgeInfo = new System.Data.DataTable();
        System.Data.DataTable dtSection = new System.Data.DataTable();
        double slope = 0;
        public AbutmentStructure(string bridgeId,  out System.Data.DataTable dtProjectTb, bool isMerge = false)
        {
   
            #region  参数数据初始化
            dtBridgeDrawing = new System.Data.DataTable();//图纸目录信息表
            //传入bridgeId，查询出mainId
            string sqlMainId = "select * from busi_bridge where id='" + bridgeId + "' ";
            _bridgeId = bridgeId;
            string mainId = MySqlHelper.ExecuteDataTable(sqlMainId, CommandType.Text).Rows[0]["main_id"].ToString();
            _bridgeMainId = mainId;
            string sqlBridge = "select * from busi_bridge_main where id='" + mainId + "'";
            dtBridge = MySqlHelper.ExecuteDataTable(sqlBridge, CommandType.Text);

            int bridge_scope = 1;//桥幅（单幅桥和双幅桥）
            if (dtBridge.Rows.Count > 0)
            {
                bridge_scope = int.Parse(dtBridge.Rows[0]["bridge_scope"].ToString());
                if (bridge_scope > 0)
                    isMerge = dtBridge.Rows[0]["drawing_level"].ToString() == "1" ? true : false; //双幅桥图纸是否合并
            }


            string sqlDrawing = "select * from busi_bridge_catalog where  bridge_main_id='" + mainId + "'";
            dtBridgeDrawing = MySqlHelper.ExecuteDataTable(sqlDrawing, CommandType.Text);

            string sqlBridge1 = "select * from vi_bridge where  id='" + mainId + "'";
            dtAviationBridgeInfo = MySqlHelper.ExecuteDataTable(sqlBridge1, CommandType.Text);
            if (dtAviationBridgeInfo.Rows.Count > 0)
            {
                string sqlSpan = "select * from vi_aviation_bridge where  bridge_id='" + dtAviationBridgeInfo.Rows[0]["bridge_id"].ToString() + "' order by station asc";
                dtAviationBridge = MySqlHelper.ExecuteDataTable(sqlSpan, CommandType.Text);


                //主梁布跨信息
                string sqlSection = "select * from vi_aviation_section where  bridge_id='" + dtAviationBridgeInfo.Rows[0]["bridge_id"].ToString() + "' ";
                dtSection = MySqlHelper.ExecuteDataTable(sqlSection, CommandType.Text);
            }
            #endregion

            dtProjectTb = dtBridgeDrawing;
        }

     
        public void InitAbutmentStructure()
        {
            string sqlAbutment = "select * from vi_abutment where bridge_id='" + _bridgeId + "'";
            dtAbutment = MySqlHelper.ExecuteDataTable(sqlAbutment, CommandType.Text);
            if(dtAbutment.Rows.Count>0)
            {
                DataRow dr = dtAbutment.Rows[0];
                baseType = dr["base_type"].ToString();
                string sql = "";
                // busi_abutment_back_wall_structural
                if (!dr.IsNull("abutment_back_wall_structural_id")&& !string.IsNullOrWhiteSpace(dr["abutment_back_wall_structural_id"].ToString()))
                {
                    sql = "select *from busi_abutment_back_wall_structural where id='"+ dr["abutment_back_wall_structural_id"].ToString() + "'";
                    dtAbutmentBackWall = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                //busi_abutment_body_structural
                if (!dr.IsNull("abutment_body_structural_id")&&!string.IsNullOrWhiteSpace(dr["abutment_body_structural_id"].ToString()))
                {
                    sql = "select *from busi_abutment_body_structural where id='" + dr["abutment_body_structural_id"].ToString() + "'";
                    dtAbutmentBody = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                //busi_abutment_capping_structural
                if (!dr.IsNull("abutment_capping_structural_id") && !string.IsNullOrWhiteSpace(dr["abutment_capping_structural_id"].ToString()))
                {
                    sql = "select *from busi_abutment_capping_structural where id='" + dr["abutment_capping_structural_id"].ToString() + "'";
                    dtAbutmentCap = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                //busi_abutment_ear_wall_structural
                if (!dr.IsNull("abutment_ear_wall_structural_id") && !string.IsNullOrWhiteSpace(dr["abutment_ear_wall_structural_id"].ToString()))
                {
                    sql = "select *from busi_abutment_ear_wall_structural where id='" + dr["abutment_ear_wall_structural_id"].ToString() + "'";
                    dtAbutmentEarWall = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                //busi_abutment_ladder_structural
                if (!dr.IsNull("ladder_structural_id") && !string.IsNullOrWhiteSpace(dr["ladder_structural_id"].ToString()))
                {
                    sql = "select *from busi_abutment_ladder_structural where id='" + dr["ladder_structural_id"].ToString() + "'";
                    dtAbutmentLadder = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                //busi_cushion_stone_structural
                if (!dr.IsNull("cushion_stone_structural_id") && !string.IsNullOrWhiteSpace(dr["cushion_stone_structural_id"].ToString()))
                {
                    sql = "select *from busi_cushion_stone_structural where id='" + dr["cushion_stone_structural_id"].ToString() + "'";
                    dtCushionStone = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                //busi_pile_cap_structural
                if (!dr.IsNull("pile_cap_structural_id") && !string.IsNullOrWhiteSpace(dr["pile_cap_structural_id"].ToString()))
                {
                    sql = "select *from busi_pile_cap_structural where id='" + dr["pile_cap_structural_id"].ToString() + "'";
                    dtPileCap = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                //busi_pile_structural
                if (!dr.IsNull("pile_structural_id") && !string.IsNullOrWhiteSpace(dr["pile_structural_id"].ToString()))
                {
                    sql = "select *from busi_pile_structural where id='" + dr["pile_structural_id"].ToString() + "'";
                    dtPile = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                if (!dr.IsNull("spread_foundation_structural_id") && !string.IsNullOrWhiteSpace(dr["spread_foundation_structural_id"].ToString()))
                {
                    sql = "select *from busi_spread_foundation_structural where id='" + dr["spread_foundation_structural_id"].ToString() + "'";
                    dtSpreadFoundation = MySqlHelper.ExecuteDataTable(sql, CommandType.Text);
                }
                
            }
        }


        public void DrawingAbutmentStructure(Database db, DrawingConfigModel drawingConfigModel, string bridgeId, string categoryId, System.Data.DataRow dr, int page, int count,  double bridgeW, double divCap)
        {
            InitAbutmentStructure();
            string sqlBridgeConfig = "select * from busi_project_config where bridge_id='" + bridgeId + "'";
            System.Data.DataTable dtProjectConfig = MySqlHelper.ExecuteDataTable(sqlBridgeConfig, CommandType.Text);
            PictureFrameTools.GetBridgeConfig(dtProjectConfig);
            int OverAllScale = drawingConfigModel.drawing_scale;
            if (baseType == "2")
            {
                List<Tuple<int,double, List<Extents2d>>> tuPage = new List<Tuple<int, double,List<Extents2d>>>();
                CushionStoneSteel P1 = new CushionStoneSteel(bridgeId, BridgeStructureType.AviationBridge, out dtProject);
                
                System.Data.DataTable dt1; System.Data.DataTable dt2;
                Extents2d ExtPlan, ExtE, ExtSection, ExtDetail, ExtDetailSection;
                Point2d RefPtPlan, RefPtE, RefPtSection, RefPtDetail, RefPtDetailSection;

                RefPtE = Point2d.Origin;
                ExtE = new Extents2d(RefPtE, RefPtE);

                try
                {
                    PlotElevation(ref db, out ExtE, RefPtE, OverAllScale);
                }
                catch { }
                double h = ExtE.L();
                RefPtPlan = RefPtE.C2D(0, ExtE.L() * 1.5);
                ExtPlan = new Extents2d(RefPtPlan, RefPtPlan);

                try
                {
                    PlotPlan(ref db, out ExtPlan, RefPtPlan.C2D(), OverAllScale);
                }
                catch { }

                RefPtDetail= RefPtPlan.C2D(ExtPlan.W() * 1.5);
                RendeDetail(ref db, RefPtDetail, out ExtDetail, OverAllScale);
           
                //LayoutTools.CreateLayout2LRDiv(db, "图纸", ExtE, ExtPlan, ExtDetail,
                //   Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale);
                List<Extents2d> lst = new List<Extents2d>();
                lst.Add(ExtE);
                lst.Add(ExtPlan);
                lst.Add(ExtDetail);
                Tuple<int, double, List<Extents2d>> tu = new Tuple<int, double, List<Extents2d>>(1,OverAllScale,lst);
                tuPage.Add(tu);
                RefPtSection = RefPtDetail.C2D(ExtPlan.W() * 1.5);
                ExtSection = new Extents2d(RefPtSection, RefPtSection);
                try
                {
                    PlotSectionA(ref db, out ExtSection, RefPtSection.C2D(), OverAllScale);
                    PlotSectionB(ref db, ref ExtSection, RefPtSection.C2D(9, -ExtSection.L() - 10 * OverAllScale), OverAllScale);
                }
                catch { }

                RefPtDetailSection = RefPtSection.C2D(ExtSection.W()*1.5);
                PlotSampleDetail(ref db, RefPtDetailSection, out ExtDetailSection, OverAllScale);

                lst = new List<Extents2d>();
                lst.Add(ExtSection);
                lst.Add(ExtDetailSection);
                tu = new Tuple<int, double, List<Extents2d>>(2, OverAllScale, lst);
                tuPage.Add(tu);
                //LayoutTools.CreateLayout2LRDiv(db, "图纸", ExtE, ExtPlan, ExtDetailSection,
                //   Extensions.leftWidth, 5, Extensions.bottomHeight, 10, OverAllScale);
                lst = new List<Extents2d>();
                P1.DrawingPlinth(db, RefPtDetailSection.C2D(ExtDetailSection.W() * 1.5), 10, bridgeId, out dtProjectConfig, categoryId,ref lst);
                tu = new Tuple<int, double, List<Extents2d>>(3, 10, lst);
                tuPage.Add(tu);

                LayoutTools.CreateAbutmentLayout(db, "图纸", tuPage,
                   Extensions.leftWidth, 5, Extensions.bottomHeight, 10);

                Point2d tKPoint = Point2d.Origin;
                Extents2d ex = new Extents2d();
                PictureFrameTools.AddPaperDBText(db, tKPoint, drawingConfigModel, ref ex, tuPage.Count, 1);
            }
        }

        #region 扩基
        // 绘制立面图
        public void PlotElevation(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            ext = new Extents2d(insertPoint, insertPoint);
            TextPloter.AddTitle(db, insertPoint, ref ext, "立面", "", scale);
            double maxH = 0;
            if (dtAbutmentBody.Rows.Count > 0)
            {
                maxH = double.Parse(dtAbutmentBody.Rows[0]["height"].ToString());
            }
            if (dtAbutmentBackWall.Rows.Count > 0)
            {
                maxH = maxH > double.Parse(dtAbutmentBackWall.Rows[0]["height"].ToString()) ? maxH : double.Parse(dtAbutmentBackWall.Rows[0]["height"].ToString());
            }
            if (dtAbutmentEarWall.Rows.Count > 0)
            {
                maxH = maxH > double.Parse(dtAbutmentEarWall.Rows[0]["height"].ToString()) ? maxH : double.Parse(dtAbutmentEarWall.Rows[0]["height"].ToString());
            }
            maxH = maxH * 1000;
            Point2d pt = insertPoint.C2D(0, -15 * scale);
            Point2d ptDimL = pt;
            Point2d ptDimR = pt;
            //中心线
            Point2d ptS = pt;
            Point2d ptFS = pt;
            double capH = 0, hCap = 0, capW = 0, capL = 0, capTW = 0, capTL = 0;
            int layer = 2;
            //基础
            if (dtSpreadFoundation.Rows.Count > 0)
            {
                string section_type = dtSpreadFoundation.Rows[0]["section_type"].ToString();
                if (section_type == "1")//矩形扩基
                {
                    #region 矩形扩基
                    capW = double.Parse(dtSpreadFoundation.Rows[0]["width"].ToString()) * 10;
                    capL = double.Parse(dtSpreadFoundation.Rows[0]["length"].ToString()) * 10;
                    capH = double.Parse(dtSpreadFoundation.Rows[0]["height"].ToString()) * 10;
                    double wCap = double.Parse(dtSpreadFoundation.Rows[0]["width_cap"].ToString()) * 10;
                    double lCap = double.Parse(dtSpreadFoundation.Rows[0]["length_cap"].ToString()) * 10;
                    hCap = double.Parse(dtSpreadFoundation.Rows[0]["height_cap"].ToString()) * 10;
                    layer = int.Parse(dtSpreadFoundation.Rows[0]["layer"].ToString());

                    //中心线
                    ptS = pt.C2D(0, -maxH - capH - (layer - 1) * hCap);
                    PLPloter.AddScaleLine(db, pt.C2D(0, 2 * scale), ptS.C2D(0, -2 * scale), ref ext, "H中心线", 5);
                    PLPloter.AddPoly8(db, ptS.C2D(0, capH), ref ext, capH, capW, "H虚线", 100, capH, 0,0);

                    ptDimL = ptS.C2D(-capW * 0.5 - 5 * scale);
                    ptDimR = ptS.C2D(capW * 0.5 + 5 * scale);
                    for (int i = 0; i < layer - 1; i++)
                    {
                        PLPloter.AddPloy4(db, ptS.C2D(0, capH + (i + 1) * hCap), (capW - (i + 1) * wCap * 2) * 0.5, (capW - (i + 1) * wCap * 2) * 0.5, hCap, ref ext, "H粗线");

                        DimPloter.DimAli(db, ptS.C3D(0, capH + (i + 1) * hCap), ptS.C3D(0, capH + (i + 1) * hCap - hCap), ptDimL.C3D(-5 * scale), ref ext, scale);
                    }
                    DimPloter.DimAli(db, ptS.C3D(0, capH), ptS.C3D(), ptDimL.C3D(-5 * scale), ref ext, scale);
                    ptFS = ptS.C2D(0, capH + (layer - 1) * hCap);
                    capTW = capW - (layer - 1) * wCap * 2;
                    capTL = capL - (layer - 1) * lCap * 2;
                    #endregion
                }
            }

            DimPloter.DimAli(db, ptS.C3D(0, capH), ptS.C3D(0, maxH + capH + (layer - 1) * hCap), ptDimL.C3D(-10 * scale), ref ext, scale);

            //外轮廓
            PLPloter.AddLine(db, ptS.C2D(-(capW * 0.5 + 2 * scale), maxH + capH + (layer - 1) * hCap), ptS.C2D(capW * 0.5 + 2 * scale, maxH + capH + (layer - 1) * hCap), ref ext, "H细线");
            PLPloter.AddLine(db, ptS.C2D(-(capW * 0.5 + 2 * scale), -capH), ptS.C2D(capW * 0.5 + 2 * scale, -capH), ref ext, "H细线");
            RebarPLPloter.CreateBreakLine(db, ref ext, ptS.C2D(-(capW * 0.5 + 2 * scale), -capH), ptS.C2D(-(capW * 0.5 + 2 * scale), maxH + capH + (layer - 1) * hCap), scale);
            RebarPLPloter.CreateBreakLine(db, ref ext, ptS.C2D((capW * 0.5 + 2 * scale), -capH), ptS.C2D((capW * 0.5 + 2 * scale), maxH + capH + (layer - 1) * hCap), scale);



            //台身、背墙
            double refer_location = double.Parse(dtAbutment.Rows[0]["refer_location"].ToString()) * 10;
            double refer_body_distinct = double.Parse(dtAbutment.Rows[0]["refer_body_distinct"].ToString()) * 10;
            double bw = 0;
            double ibeamH = 0;
            if (dtAbutmentBody.Rows.Count > 0)
            {
                #region 台身
                double bodyH = double.Parse(dtAbutmentBody.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentBody.Rows[0]["top_w"].ToString()) * 1000;
                double ibeam_height = double.Parse(dtAbutmentBody.Rows[0]["ibeam_height"].ToString()) * 1000;
                double ibeam_width = double.Parse(dtAbutmentBody.Rows[0]["ibeam_width"].ToString()) * 1000;
                ibeamH = ibeam_height;
                bw = top_w;
                List<Point2d> ptLst = new List<Point2d>();
                Point2d p1 = pt.C2D(-ibeam_width * 0.5, -ibeam_height);
                Point2d p2 = pt.C2D(ibeam_width * 0.5, -ibeam_height);
                Point2d p11 = pt.C2D(-ibeam_width * 0.5, 0);
                Point2d p22 = pt.C2D(ibeam_width * 0.5, 0);
                Point2d p3 = pt.C2D(-top_w * 0.5, 0);
                Point2d p4 = pt.C2D(top_w * 0.5, 0);
                Point2d p5 = pt.C2D(-top_w * 0.5, -bodyH);
                Point2d p6 = pt.C2D(top_w * 0.5, -bodyH);
                ptLst.Add(p3);
                ptLst.Add(p11);
                ptLst.Add(p1);
                ptLst.Add(p2);
                ptLst.Add(p22);
                ptLst.Add(p4);
                ptLst.Add(p6);
                ptLst.Add(p5);

                PLPloter.AddPolylineByPointList(db, ptLst, ref ext, "H细线", true);

                DimPloter.DimAli(db, p1.C3D(), p2.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p11.C3D(), p3.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p22.C3D(), p4.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                //DimPloter.DimAli(db, p3.C3D(), p4.C3D(), pt.C3D(0, 10 * scale), ref ext, scale);

                DimPloter.DimAli(db, p1.C3D(), p11.C3D(), p1.C3D(5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p3.C3D(), p5.C3D(), ptDimL.C3D(-5 * scale), ref ext, scale);

                for (int i = 0; i < 6; i++)
                {
                    double hh = ibeam_height * 0.8;
                    if (i % 2 == 0)
                        hh = ibeam_height * 0.5;
                    PLPloter.AddLine(db, pt.C2D((i - 3) * 125 + 20), pt.C2D((i - 3) * 125 + 20, -hh), ref ext, "H粗线");
                }
                #endregion
            }
            if (dtAbutmentBody.Rows.Count <= 0 && dtAbutmentBackWall.Rows.Count > 0)
            {
                #region 背墙
                double bodyH = double.Parse(dtAbutmentBody.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentBody.Rows[0]["top_w"].ToString()) * 1000;
                double ibeam_height = double.Parse(dtAbutmentBody.Rows[0]["ibeam_height"].ToString()) * 1000;
                double ibeam_width = double.Parse(dtAbutmentBody.Rows[0]["ibeam_width"].ToString()) * 1000;
                ibeamH = ibeam_height;
                bw = top_w;
                List<Point2d> ptLst = new List<Point2d>();
                Point2d p1 = pt.C2D(-ibeam_width * 0.5, -ibeam_height);
                Point2d p2 = pt.C2D(ibeam_width * 0.5, -ibeam_height);
                Point2d p11 = pt.C2D(-ibeam_width * 0.5, 0);
                Point2d p22 = pt.C2D(ibeam_width * 0.5, 0);
                Point2d p3 = pt.C2D(-top_w * 0.5, 0);
                Point2d p4 = pt.C2D(top_w * 0.5, 0);
                Point2d p5 = pt.C2D(-top_w * 0.5, -bodyH);
                Point2d p6 = pt.C2D(top_w * 0.5, -bodyH);
                ptLst.Add(p3);
                ptLst.Add(p11);
                ptLst.Add(p1);
                ptLst.Add(p2);
                ptLst.Add(p22);
                ptLst.Add(p4);
                ptLst.Add(p6);
                ptLst.Add(p5);

                DimPloter.DimAli(db, p1.C3D(), p2.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p11.C3D(), p3.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p22.C3D(), p4.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);

                DimPloter.DimAli(db, p1.C3D(), p11.C3D(), p1.C3D(5 * scale), ref ext, scale);


                DimPloter.DimAli(db, p1.C3D(), p2.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p11.C3D(), p3.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p22.C3D(), p4.C3D(), pt.C3D(0, 5 * scale), ref ext, scale);
                //DimPloter.DimAli(db, p3.C3D(), p4.C3D(), pt.C3D(0, 10 * scale), ref ext, scale);

                DimPloter.DimAli(db, p1.C3D(), p11.C3D(), p1.C3D(5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p3.C3D(), p5.C3D(), ptDimL.C3D(-5 * scale), ref ext, scale);

                for (int i = 0; i < 6; i++)
                {
                    double hh = ibeam_height * 0.8;
                    if (i % 2 == 0)
                        hh = ibeam_height * 0.5;
                    PLPloter.AddLine(db, pt.C2D((i - 3) * 125 + 20), pt.C2D((i - 3) * 125 + 20, -hh), ref ext, "H粗线");
                }
                #endregion
            }
            double bAW = 0;
            //耳墙
            if (dtAbutmentEarWall.Rows.Count > 0)
            {
                #region 耳墙
                double height = double.Parse(dtAbutmentEarWall.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentEarWall.Rows[0]["top_w"].ToString()) * 1000;
                double top_l = double.Parse(dtAbutmentEarWall.Rows[0]["top_l"].ToString()) * 1000;
                double start_change_height = double.Parse(dtAbutmentEarWall.Rows[0]["start_change_height"].ToString()) * 1000;
                Point2d ptL = pt.C2D(-bw * 0.5 - top_w * 0.5, 0);
                Point2d ptR = pt.C2D(bw * 0.5 + top_w * 0.5, 0);
                bAW = bw + 2 * top_w;
                PLPloter.AddPloy4(db, ptL.C2D(), top_w * 0.5, top_w * 0.5, height, ref ext, "H粗线");
                PLPloter.AddPloy4(db, ptR.C2D(), top_w * 0.5, top_w * 0.5, height, ref ext, "H粗线");

                PLPloter.AddLine(db, ptL.C2D(-top_w * 0.5, -height + start_change_height), ptL.C2D(top_w * 0.5, -height + start_change_height), ref ext, "H粗线");
                PLPloter.AddLine(db, ptR.C2D(-top_w * 0.5, -height + start_change_height), ptR.C2D(top_w * 0.5, -height + start_change_height), ref ext, "H粗线");


                DimPloter.DimAli(db, ptL.C3D(-top_w * 0.5), ptL.C3D(top_w * 0.5), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptR.C3D(-top_w * 0.5), ptR.C3D(top_w * 0.5), pt.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptL.C3D(-top_w * 0.5), ptR.C3D(top_w * 0.5), pt.C3D(0, 10 * scale), ref ext, scale);

                Point2d ptT = ptS.C2D(-(bw * 0.5 + top_w), maxH + capH + (layer - 1) * hCap - 70);
                PLPloter.AddLine(db, ptS.C2D(-(capW * 0.5 + 2 * scale), maxH + capH + (layer - 1) * hCap - 70), ptT, ref ext, "H粗线");
                int num = (int)(capW * 0.5 + 2 * scale - (bw * 0.5 + top_w)) / 125;
                for (int i = 0; i < num; i++)
                {
                    double hh = 800;
                    if (i % 2 == 1)
                        hh = 400;
                    PLPloter.AddLine(db, ptT.C2D(-(i + 1) * 125), ptT.C2D(-(i + 1) * 125, -hh), ref ext, "H细线");
                }

                PLPloter.AddLine(db, ptS.C2D(-(capW * 0.5 + 2 * scale), capH * 2 + 100), ptS.C2D(capW * 0.5 + 2 * scale, capH * 2 + 100), ref ext, "H粗线");
                Point2d ptB = ptS.C2D((bw * 0.5 + top_w), capH * 2 + 100);
                for (int i = 0; i < num; i++)
                {
                    double hh = capH * 2 + 200;
                    if (i % 2 == 1)
                        hh = capH + 150;
                    PLPloter.AddLine(db, ptB.C2D(-(i + 1) * 125), ptB.C2D(-(i + 1) * 125, -hh), ref ext, "H细线");
                }
                #endregion
            }
            //垫石
            //台身、背墙
            double cushion_stone_capw_distinct = string.IsNullOrWhiteSpace(dtAbutment.Rows[0]["cushion_stone_capw_distinct"].ToString()) ? 0 : double.Parse(dtAbutment.Rows[0]["cushion_stone_capw_distinct"].ToString()) * 10;
            double cushion_stone_capl_distinct = string.IsNullOrWhiteSpace(dtAbutment.Rows[0]["cushion_stone_capl_distinct"].ToString()) ? 0 : double.Parse(dtAbutment.Rows[0]["cushion_stone_capl_distinct"].ToString()) * 10;
            if (dtCushionStone.Rows.Count > 0)
            {
                #region 垫石
                double length = double.Parse(dtCushionStone.Rows[0]["length"].ToString());
                double width = double.Parse(dtCushionStone.Rows[0]["width"].ToString());
                double height = double.Parse(dtCushionStone.Rows[0]["height"].ToString());

                PLPloter.AddPloy4(db, ptFS.C2D(-(capTW * 0.5 - cushion_stone_capw_distinct), height), width * 0.5, width * 0.5, height, ref ext, "H细线");
                PLPloter.AddScaleLine(db, ptFS.C2D(-(capTW * 0.5 - cushion_stone_capw_distinct), height + 2 * scale), ptFS.C2D(-(capTW * 0.5 - cushion_stone_capw_distinct), -2 * scale), ref ext, "H中心线", 2);
                DimPloter.DimAli(db, ptFS.C3D(-(capTW * 0.5 - cushion_stone_capw_distinct) - width * 0.5, height), ptFS.C3D(-(capTW * 0.5 - cushion_stone_capw_distinct) + width * 0.5, height), ptFS.C3D(0, height + 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-(capTW * 0.5 - cushion_stone_capw_distinct) + width * 0.5, 0), ptFS.C3D(-(capTW * 0.5 - cushion_stone_capw_distinct) + width * 0.5, height), ptFS.C3D(-(capTW * 0.5 - cushion_stone_capw_distinct) + width * 0.5 + 5 * scale, 0), ref ext, scale,height.ToString());
                PLPloter.AddPloy4(db, ptFS.C2D((capTW * 0.5 - cushion_stone_capw_distinct), height), width * 0.5, width * 0.5, height, ref ext, "H细线");
                PLPloter.AddScaleLine(db, ptFS.C2D((capTW * 0.5 - cushion_stone_capw_distinct), height + 2 * scale), ptFS.C2D((capTW * 0.5 - cushion_stone_capw_distinct), -2 * scale), ref ext, "H中心线", 2);
                DimPloter.DimAli(db, ptFS.C3D((capTW * 0.5 - cushion_stone_capw_distinct) - width * 0.5, height), ptFS.C3D((capTW * 0.5 - cushion_stone_capw_distinct) + width * 0.5, height), ptFS.C3D(0, height + 5 * scale), ref ext, scale);


                DimPloter.DimAli(db, ptFS.C3D(-capTW * 0.5, 0), ptFS.C3D(-bAW * 0.5, 0), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-bAW * 0.5, 0), ptFS.C3D(-bw * 0.5, 0), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-bw * 0.5, 0), ptFS.C3D(-(capTW * 0.5 - cushion_stone_capw_distinct), 0), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-(capTW * 0.5 - cushion_stone_capw_distinct), 0), ptFS.C3D((capTW * 0.5 - cushion_stone_capw_distinct), 0), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D((capTW * 0.5 - cushion_stone_capw_distinct), 0), ptFS.C3D(bw * 0.5, 0), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(bw * 0.5, 0), ptFS.C3D(bAW * 0.5, 0), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(bAW * 0.5, 0), ptFS.C3D(capTW * 0.5, 0), ptFS.C3D(0, -5 * scale), ref ext, scale);
                #endregion
            }

            DimPloter.DimAli(db, ptS.C3D(0, maxH + capH + (layer - 1) * hCap - ibeamH), ptFS.C3D(), ptFS.C3D(5 * scale), ref ext, scale);
            //爬梯
            if (dtAbutmentLadder.Rows.Count > 0)
            {
                #region 爬梯
                double divcap = double.Parse(dtAbutmentLadder.Rows[0]["divcap"].ToString())*10;
                double width = double.Parse(dtAbutmentLadder.Rows[0]["width"].ToString()) * 10;
                double height = double.Parse(dtAbutmentLadder.Rows[0]["height"].ToString())*1000;
                double bottom_start_height = double.Parse(dtAbutmentLadder.Rows[0]["bottom_start_height"].ToString()) * 10;
                double bottom_extend_length = double.Parse(dtAbutmentLadder.Rows[0]["bottom_extend_length"].ToString()) * 10;
                double top_start_height = double.Parse(dtAbutmentLadder.Rows[0]["top_start_height"].ToString()) * 10;
                double start_ladder_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_length"].ToString()) * 10;
                double start_ladder_ear_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_ear_length"].ToString()) * 10;

                Point2d ptLadderS = ptFS.C2D(bAW*0.5+ width * 0.5, 0);
                PLPloter.AddPloy4(db, ptLadderS.C2D(0, height), width * 0.5, width * 0.5, height, ref ext, "H细线");
                PLPloter.AddPloy4(db, ptLadderS.C2D(width*0.5+ top_start_height * 0.5, height), top_start_height * 0.5, top_start_height * 0.5, height, ref ext, "H细线");
                int numL = (int)((height- start_ladder_length) / divcap);
                PLPloter.AddLine(db, ptLadderS.C2D(width * 0.5,  divcap), ptLadderS.C2D(width * 0.5+ top_start_height,  divcap), ref ext, "H细线");
                for (int i=1;i<= numL;i++)
                {
                    PLPloter.AddLine(db, ptLadderS.C2D(-width * 0.5, i * divcap), ptLadderS.C2D(width * 0.5, i * divcap), ref ext, "H细线");
                }
                DimPloter.DimAli(db, ptLadderS.C3D(width * 0.5, 0), ptLadderS.C3D(width * 0.5+ top_start_height, 0), ptFS.C3D(0, -5 * scale), ref ext, scale, top_start_height.ToString());
                DimPloter.DimAli(db, ptLadderS.C3D(width * 0.5, 0), ptLadderS.C3D(width * 0.5, divcap* (numL)), ptDimR.C3D(5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptLadderS.C3D(width * 0.5, divcap * (numL)), ptLadderS.C3D(width * 0.5, height), ptDimR.C3D(5 * scale), ref ext, scale);


                DimPloter.AddMultiMLeader(db, ptLadderS.C2D(0,height-1*scale), ptLadderS.C2D(capW * 0.5 - bAW * 0.5 - width + 3 * scale, height+ 3 * scale), ptLadderS.C2D(capW * 0.5 - bAW * 0.5 - width + 3 * scale, height+ 3 * scale), "检修爬梯", ref ext, scale);

                DimPloter.AddTop2BottomBJ(db, "B", ptLadderS.C3D(-width*0.3, height +15 * scale), ref ext, scale, 3, true);
                DimPloter.AddTop2BottomBJ(db, "B", ptLadderS.C3D(-width * 0.3, -10 * scale), ref ext, scale, 3, false);
                #endregion

            }

            DimPloter.AddTop2BottomBJ(db, "A", pt.C3D(-15 * scale, 15 * scale), ref ext, scale, 3, true);
            DimPloter.AddTop2BottomBJ(db, "A", ptS.C3D(-15*scale, -10 * scale), ref ext, scale, 3, false);
            //其它
            double pipe_height = string.IsNullOrWhiteSpace(dtAbutment.Rows[0]["pipe_height"].ToString()) ? 0 : double.Parse(dtAbutment.Rows[0]["pipe_height"].ToString()) * 10;
            double pipe_divcap = string.IsNullOrWhiteSpace(dtAbutment.Rows[0]["pipe_divcap"].ToString()) ? 0 : double.Parse(dtAbutment.Rows[0]["pipe_divcap"].ToString()) * 10;
            int numP = (int)(bw*0.5 / pipe_divcap);
            Point2d ptP = ptFS.C2D(0, pipe_height);
            for(int i=0;i<= numP;i++)
            {
                PLPloter.AddCircle(db, ptP.C2D(pipe_divcap*i), 30, ref ext);
                PLPloter.AddCircle(db, ptP.C2D(pipe_divcap * i, pipe_divcap*2), 30, ref ext);
                if (i > 0)
                {
                    PLPloter.AddCircle(db, ptP.C2D(-pipe_divcap * i), 30, ref ext);
                    PLPloter.AddCircle(db, ptP.C2D(-pipe_divcap * i, pipe_divcap * 2), 30, ref ext);

                    PLPloter.AddCircle(db, ptP.C2D(-pipe_divcap * i+pipe_divcap*0.5, pipe_divcap), 30, ref ext);
                    PLPloter.AddCircle(db, ptP.C2D(pipe_divcap * i - pipe_divcap * 0.5, pipe_divcap), 30, ref ext);
                }
            }
            RebarDimPloter.CreateLeadWireWithoutCircleMark(db, ref ext, ptP.C3D(), "Ф60排水管", "间距"+ pipe_divcap+",梅花形布置", Extensions.curFont, scale, 11 * scale, 2 * scale);

        }



        /// <summary>
        /// 绘制平面图
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="insertPoint"></param>
        /// <param name="scale"></param>
        public void PlotPlan(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            Point2d CT = insertPoint;


            ext = new Extents2d(CT, CT);

            TextPloter.AddTitle(db, CT, ref ext, "平面", "", scale);
            Point2d pt = insertPoint.C2D(0, -30 * scale);

            //基础
            double foundL = 0;
            Point2d ptS = insertPoint.C2D(0, -25 * scale);
            Point2d ptTS = insertPoint.C2D(0, -5 * scale);
            Point2d ptA = ptTS;
            Point2d ptDimL = ptS;
            Point2d ptDimR = ptS;
            Point2d ptEnd = ptS;
            double capH = 0, hCap = 0, capW = 0, capL = 0,lCap=0, capTW = 0, capTL = 0;
            int layer = 2;
            if (dtSpreadFoundation.Rows.Count > 0)
            {
                string section_type = dtSpreadFoundation.Rows[0]["section_type"].ToString();
                if (section_type == "1")//矩形扩基
                {
                    #region 矩形扩基
                    capW = double.Parse(dtSpreadFoundation.Rows[0]["width"].ToString())*10;
                    capL = double.Parse(dtSpreadFoundation.Rows[0]["length"].ToString()) * 10;
                    capH = double.Parse(dtSpreadFoundation.Rows[0]["height"].ToString()) * 10;
                    double wCap = double.Parse(dtSpreadFoundation.Rows[0]["width_cap"].ToString()) * 10;
                    lCap = double.Parse(dtSpreadFoundation.Rows[0]["length_cap"].ToString()) * 10;
                    hCap = double.Parse(dtSpreadFoundation.Rows[0]["height_cap"].ToString()) * 10;
                    layer = int.Parse(dtSpreadFoundation.Rows[0]["layer"].ToString());

                    //中心线
                 
                  
                    ptDimL = ptS.C2D(-capW * 0.5 - 5 * scale);
                    ptDimR = ptS.C2D(capW * 0.5 + 5 * scale);
                    for (int i = 0; i < layer-1; i++)
                    {
                        PLPloter.AddPloy4(db, ptS.C2D(0,-lCap * i), capW * 0.5- wCap*(i+1), capW * 0.5- wCap * (i + 1), capL- (i+1) * lCap*2, ref ext, "H虚线");                       
                    }
                    ptS = ptS.C2D(0,-(layer - 2) * lCap);
                    foundL = capL - (layer - 1) * lCap * 2;
                    ptEnd = ptS.C2D(0, -(capL - (layer - 1) * lCap * 2));
                    DimPloter.DimAli(db, ptS.C3D(0, 0), ptEnd.C3D(0, 0), ptDimL.C3D(-10 * scale), ref ext, scale);

                    PLPloter.AddScaleLine(db, ptTS.C2D(0, 2 * scale), ptEnd.C2D(0, -capH - 2 * scale ), ref ext, "H中心线", 5);

                    capTW = capW - (layer - 1) * wCap * 2;
                    capTL = capL - (layer - 1) * lCap * 2;
                    #endregion
                }
            }

            #region 外轮廓
            PLPloter.CreateBreakLineP(db, ref ext, ptTS.C2D(-(capW * 0.5 + 2 * scale), 0), ptTS.C2D(capW * 0.5 + 2 * scale,0), scale);
            PLPloter.CreateBreakLineP(db, ref ext, ptEnd.C2D(-(capW * 0.5 + 2 * scale), - capH), ptEnd.C2D(capW * 0.5 + 2 * scale, - capH), scale);
            RebarPLPloter.CreateBreakLine(db, ref ext, ptTS.C2D(-(capW * 0.5 + 2 * scale), 0), ptEnd.C2D(-(capW * 0.5 + 2 * scale), - capH), scale);
            RebarPLPloter.CreateBreakLine(db, ref ext, ptTS.C2D((capW * 0.5 + 2 * scale), 0), ptEnd.C2D((capW * 0.5 + 2 * scale), - capH), scale);
            #endregion

            //台身、背墙
            double refer_location = double.Parse(dtAbutment.Rows[0]["refer_location"].ToString())*10;
            double refer_body_distinct = double.Parse(dtAbutment.Rows[0]["refer_body_distinct"].ToString()) * 10;
            double bw = 0,bl=0,bAW=0,ibeamW=0;
          
            if (dtAbutmentBody.Rows.Count > 0)
            {
                double bodyH = double.Parse(dtAbutmentBody.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentBody.Rows[0]["top_w"].ToString()) * 1000;
                double top_l = double.Parse(dtAbutmentBody.Rows[0]["top_l"].ToString()) * 1000;
                double ibeam_width = double.Parse(dtAbutmentBody.Rows[0]["ibeam_width"].ToString()) * 1000;
                ibeamW = ibeam_width;
                bw = top_w;
                bl = top_l;
            }
            if (dtAbutmentBody.Rows.Count <= 0 && dtAbutmentBackWall.Rows.Count > 0)
            {
                double bodyH = double.Parse(dtAbutmentBackWall.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentBackWall.Rows[0]["top_w"].ToString()) * 1000;
                double top_l = double.Parse(dtAbutmentBackWall.Rows[0]["top_l"].ToString()) * 1000;
                double ibeam_width = double.Parse(dtAbutmentBackWall.Rows[0]["ibeam_width"].ToString()) * 1000;
                ibeamW = ibeam_width;
                bw = top_w;
                bl += top_l;
            }

            PLPloter.AddScaleLine(db, ptS.C2D(-bw * 0.5+2*scale, -foundL * 0.5 + refer_location), ptS.C2D(bw * 0.5- 2 * scale, -foundL * 0.5 + refer_location), ref ext, "H中心线", 5);

            DimPloter.AddMultiMLeader(db, ptS.C2D( -2 * scale, -foundL * 0.5 + refer_location), ptS.C2D( 2 * scale, -foundL * 0.5 + refer_location+2*scale), ptS.C2D( 2 * scale, -foundL * 0.5 + refer_location + 2 * scale), "理论跨经线", ref ext, scale);
            DimPloter.AddMultiMLeader(db, ptS.C2D(-4 * scale, -foundL * 0.5 + refer_location), ptS.C2D(0 * scale, -foundL * 0.5 + refer_location - 4 * scale), ptS.C2D(0 * scale, -foundL * 0.5 + refer_location - 4 * scale), "支座中心线", ref ext, scale);

            //耳墙
            if (dtAbutmentEarWall.Rows.Count > 0)
            {
                #region 桥台(台身+耳墙)
                double height = double.Parse(dtAbutmentEarWall.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentEarWall.Rows[0]["top_w"].ToString()) * 1000;
                double top_l = double.Parse(dtAbutmentEarWall.Rows[0]["top_l"].ToString()) * 1000;
                double start_change_height = double.Parse(dtAbutmentEarWall.Rows[0]["start_change_height"].ToString()) * 1000;
                double slope_l = double.Parse(dtAbutmentEarWall.Rows[0]["slope_l"].ToString()) ;
                double slope_w = double.Parse(dtAbutmentEarWall.Rows[0]["slope_w"].ToString());
                ptA = ptS.C2D(0, -foundL * 0.5+ refer_location + refer_body_distinct + bl);
                double bottomL = top_l + (height - start_change_height) * slope_l;
                double bottomW = top_w + (height) * slope_w;

                bAW = bw + bottomW * 2;
                List<Point2d> ptLst = new List<Point2d>();
                Point2d p1 = ptA.C2D(-bw * 0.5- bottomW, 0);
                Point2d p2 = ptA.C2D(bw * 0.5+ bottomW, 0);                          
                Point2d p3 = ptA.C2D(bw * 0.5 + bottomW,- bottomL);              
                Point2d p4 = ptA.C2D(bw * 0.5, -bottomL);            
                Point2d p5 = ptA.C2D(bw * 0.5, -bl);
                Point2d p6 = ptA.C2D(-bw * 0.5, -bl);
                Point2d p7 = ptA.C2D(-bw * 0.5, -bottomL);
                Point2d p8 = ptA.C2D(-bw * 0.5 - bottomW, -bottomL);
               
             
                ptLst.Add(p1);
                ptLst.Add(p2);
                ptLst.Add(p3);
                ptLst.Add(p4);
                ptLst.Add(p5);
                ptLst.Add(p6);
                ptLst.Add(p7);
                ptLst.Add(p8);
                PLPloter.AddPolylineByPointList(db, ptLst, ref ext, "H粗线", true);
                DimPloter.DimAli(db, ptEnd.C3D(-bw * 0.5, 0), p7.C3D(), p7.C3D(5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p7.C3D(), p8.C3D(), p7.C3D(0,5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p3.C3D(), p4.C3D(), p4.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p4.C3D(), p7.C3D(), p7.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p3.C3D(), p8.C3D(), p7.C3D(0, 10 * scale), ref ext, scale);

                PLPloter.AddLine(db, ptS.C2D(-bw * 0.5, -foundL * 0.5 + refer_location + 50), ptS.C2D(-bw * 0.5 - bottomW, -foundL * 0.5 + refer_location + 50), ref ext, "H细线");
                PLPloter.AddLine(db, ptS.C2D( bw * 0.5, -foundL * 0.5 + refer_location + 50), ptS.C2D( bw * 0.5 + bottomW, -foundL * 0.5 + refer_location + 50), ref ext, "H细线");

                int num = (int)(capW * 0.5 + 2 * scale - (bw * 0.5 + top_w)) / 125;
                PLPloter.AddLine(db, ptS.C2D(-(capW * 0.5 + 2 * scale), -foundL * 0.5 + refer_location + refer_body_distinct), p6.C2D( - bottomW), ref ext, "H粗线");
                //PLPloter.AddLine(db, ptS.C2D((capW * 0.5 + 2 * scale), -foundL * 0.5 + refer_location + refer_body_distinct), p5.C2D(-bottomW), ref ext, "H细线");
                for (int i = 0; i < num; i++)
                {
                    double hh = 800;
                    if (i % 2 == 1)
                        hh = 400;
                    PLPloter.AddLine(db, p6.C2D(-(i + 1) * 125- bottomW), p6.C2D(-(i + 1) * 125- bottomW, -hh), ref ext, "H细线");
                    //PLPloter.AddLine(db, p5.C2D((i + 1) * 125+ bottomW), p5.C2D((i + 1) * 125+ bottomW, -hh), ref ext, "H细线");
                }
                #endregion
            }

            #region 桥台标注
            DimPloter.DimAli(db, ptEnd.C3D(-bw * 0.5, 0), ptS.C3D(-bw * 0.5, -foundL * 0.5 + refer_location), ptDimL.C3D(-5 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptS.C3D(-bw * 0.5, -foundL * 0.5 + refer_location), ptS.C3D(-bw * 0.5, -foundL * 0.5 + refer_location + refer_body_distinct), ptDimL.C3D(-5 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptS.C3D(-bw * 0.5, -foundL * 0.5 + refer_location + refer_body_distinct), ptS.C3D(-bw * 0.5, -foundL * 0.5 + refer_location + refer_body_distinct+bl), ptDimL.C3D(-5 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptS.C3D(-bw * 0.5, -foundL * 0.5 + refer_location + refer_body_distinct+bl), ptS.C3D(-bw * 0.5, 0), ptDimL.C3D(-5 * scale), ref ext, scale);


            DimPloter.DimAli(db, ptA.C3D(-bAW * 0.5, 0), ptA.C3D(-ibeamW * 0.5, 0), ptA.C3D(0,-bl*0.75), ref ext, scale);
            DimPloter.DimAli(db, ptA.C3D(-ibeamW * 0.5, 0), ptA.C3D(ibeamW * 0.5, 0), ptA.C3D(0, -bl * 0.75), ref ext, scale);
            DimPloter.DimAli(db, ptA.C3D(ibeamW * 0.5, 0), ptA.C3D(bAW * 0.5, 0), ptA.C3D(0, -bl * 0.75), ref ext, scale);
            DimPloter.DimAli(db, ptA.C3D(ibeamW * 0.25, 0), ptA.C3D(ibeamW * 0.25, -bl), ptA.C3D(ibeamW * 0.25+5*scale, -bl * 0.75), ref ext, scale);

            DimPloter.DimAli(db, ptEnd.C3D(-capTW * 0.5, 0), ptEnd.C3D(-bAW * 0.5, 0), ptEnd.C3D(0, -10 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptEnd.C3D(-bAW * 0.5, 0), ptEnd.C3D(-bw * 0.5, 0), ptEnd.C3D(0, -10 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptEnd.C3D(-bw * 0.5, 0), ptEnd.C3D(bw * 0.5, 0), ptEnd.C3D(0, -10 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptEnd.C3D(bw * 0.5, 0), ptEnd.C3D(bAW * 0.5, 0), ptEnd.C3D(0, -10 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptEnd.C3D(bAW * 0.5, 0), ptEnd.C3D(capTW * 0.5, 0),  ptEnd.C3D(0, -10 * scale), ref ext, scale);          
            DimPloter.DimAli(db, ptEnd.C3D(-capTW * 0.5, 0), ptEnd.C3D(capTW * 0.5, 0), ptEnd.C3D(0,-15 * scale), ref ext, scale);
            #endregion

            //垫石
            //垫石
            //台身、背墙
            double cushion_stone_capw_distinct = string.IsNullOrWhiteSpace(dtAbutment.Rows[0]["cushion_stone_capw_distinct"].ToString()) ? 0 : double.Parse(dtAbutment.Rows[0]["cushion_stone_capw_distinct"].ToString()) * 10;
            double cushion_stone_capl_distinct = string.IsNullOrWhiteSpace(dtAbutment.Rows[0]["cushion_stone_capl_distinct"].ToString()) ? 0 : double.Parse(dtAbutment.Rows[0]["cushion_stone_capl_distinct"].ToString()) * 10;
            if (dtCushionStone.Rows.Count > 0)
            {
                #region 垫石
                double length = double.Parse(dtCushionStone.Rows[0]["length"].ToString());
                double width = double.Parse(dtCushionStone.Rows[0]["width"].ToString());
                double height = double.Parse(dtCushionStone.Rows[0]["height"].ToString());

                Point2d ptSL = ptS.C2D(-(capTW * 0.5 - cushion_stone_capw_distinct), -cushion_stone_capl_distinct);
                Point2d ptSR = ptS.C2D((capTW * 0.5 - cushion_stone_capw_distinct), -cushion_stone_capl_distinct);
                PLPloter.AddPloy4(db, ptSL.C2D(0,length*0.5), width * 0.5, width * 0.5, length, ref ext, "H细线");
                PLPloter.AddPloy4(db, ptSL.C2D(0, length * 0.25), width * 0.25, width * 0.25, length*0.5, ref ext, "H细线");
                PLPloter.AddScaleLine(db, ptSL.C2D(0, length * 0.5 + 1 * scale), ptSL.C2D(0, -length * 0.5 - 1 * scale), ref ext, "H中心线", 2);
                PLPloter.AddCircle(db, ptSL, length * 0.1, ref ext, "H细线");
                DimPloter.DimAli(db, ptSL.C3D(-width * 0.5, length * 0.5), ptSL.C3D(width * 0.5, length * 0.5), ptSL.C3D(0, -length*0.5 - 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptSL.C3D(width * 0.5, length * 0.5), ptSL.C3D(width * 0.5, -length * 0.5), ptSL.C3D(-width * 0.5 - 5 * scale), ref ext, scale);
                PLPloter.AddPloy4(db, ptSR.C2D(0, length * 0.5), width * 0.5, width * 0.5, length, ref ext, "H细线");
                PLPloter.AddPloy4(db, ptSR.C2D(0, length * 0.25), width * 0.25, width * 0.25, length * 0.5, ref ext, "H细线");
                PLPloter.AddScaleLine(db, ptSR.C2D(0, length * 0.5 + 1 * scale), ptSR.C2D(0, -length * 0.5 - 1 * scale), ref ext, "H中心线", 2);
                PLPloter.AddCircle(db, ptSR, length * 0.1, ref ext, "H细线");
                DimPloter.DimAli(db, ptSR.C3D(-width * 0.5, length * 0.5), ptSR.C3D(width * 0.5, length * 0.5), ptSR.C3D(0, -length * 0.5 - 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptSR.C3D(width * 0.5, length * 0.5), ptSR.C3D(width * 0.5, -length * 0.5), ptSR.C3D(width * 0.5 + 5 * scale), ref ext, scale);


                DimPloter.AddMultiMLeader(db, ptSL.C2D(width * 0.25, -length * 0.5), ptSL.C2D(width * 0.55, -length * 0.5-3*scale), ptSL.C2D(width * 0.55, -length * 0.5 - 3 * scale), "垫石", ref ext, scale);
                DimPloter.AddMultiMLeader(db, ptSL.C2D(width * 0.25, -length * 0.25), ptSL.C2D(width * 0.55, -length * 0.25+ 3 * scale), ptSL.C2D(width * 0.55, -length * 0.25 +3 * scale), "支座", ref ext, scale);

                #endregion
            }

            //爬梯
            if (dtAbutmentLadder.Rows.Count > 0)
            {
                #region 爬梯
                double divcap = double.Parse(dtAbutmentLadder.Rows[0]["divcap"].ToString()) * 10;
                double width = double.Parse(dtAbutmentLadder.Rows[0]["width"].ToString()) * 10;
                double height = double.Parse(dtAbutmentLadder.Rows[0]["height"].ToString()) * 1000;
                double bottom_start_height = double.Parse(dtAbutmentLadder.Rows[0]["bottom_start_height"].ToString()) * 10;
                double bottom_extend_length = double.Parse(dtAbutmentLadder.Rows[0]["bottom_extend_length"].ToString()) * 10;
                double top_start_height = double.Parse(dtAbutmentLadder.Rows[0]["top_start_height"].ToString()) * 10;
                double start_ladder_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_length"].ToString()) * 10;
                double start_ladder_ear_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_ear_length"].ToString()) * 10;

                int numL = (int)((height - start_ladder_length) / divcap);
                Point2d ptLadderS = ptA.C2D(bAW * 0.5 + width * 0.5, -bl);
                double ladderW = top_start_height+ start_ladder_length + (numL-1) * divcap;
                PLPloter.AddPloy4(db, ptLadderS.C2D(0, top_start_height), width * 0.5, width * 0.5, ladderW, ref ext, "H细线");
                PLPloter.AddPloy4(db, ptLadderS.C2D(width * 0.5 + top_start_height * 0.5, top_start_height), top_start_height * 0.5, top_start_height * 0.5, ladderW+ start_ladder_ear_length, ref ext, "H细线");

                PLPloter.AddLine(db, ptLadderS.C2D(width * 0.5, top_start_height - (ladderW + start_ladder_ear_length)), ptLadderS.C2D(width * 0.5, top_start_height - (ladderW + start_ladder_ear_length)- bottom_extend_length), ref ext, "H细线");
                PLPloter.AddLine(db, ptLadderS.C2D(-width * 0.5, 0), ptLadderS.C2D(width * 0.5, 0), ref ext, "H细线");
                PLPloter.AddLine(db, ptLadderS.C2D(width * 0.5, -start_ladder_ear_length), ptLadderS.C2D(width * 0.5+ top_start_height, -start_ladder_ear_length), ref ext, "H细线");
                for (int i = 1; i <= numL; i++)
                {
                    PLPloter.AddLine(db, ptLadderS.C2D(-width * 0.5, -start_ladder_length - (i-1) * divcap), ptLadderS.C2D(width * 0.5, -start_ladder_length - (i - 1) * divcap), ref ext, "H细线");
                }
                //DimPloter.DimAli(db, ptLadderS.C3D(width * 0.5, 0), ptLadderS.C3D(width * 0.5 + top_start_height, 0), ptA.C3D(0, -5 * scale), ref ext, scale, top_start_height.ToString());
                //DimPloter.DimAli(db, ptLadderS.C3D(width * 0.5, 0), ptLadderS.C3D(width * 0.5, divcap * (numL - 1)), ptDimR.C3D(5 * scale), ref ext, scale);
                //DimPloter.DimAli(db, ptLadderS.C3D(width * 0.5, divcap * (numL - 1)), ptLadderS.C3D(width * 0.5, height), ptDimR.C3D(5 * scale), ref ext, scale);

                int num = (int)(capW * 0.5 + 2 * scale - (bAW * 0.5 + width+ top_start_height)) / 125;
                PLPloter.AddLine(db, ptS.C2D((capW * 0.5 + 2 * scale), -foundL * 0.5 + refer_location + refer_body_distinct), ptLadderS.C2D(width * 0.5), ref ext, "H粗线");
                //PLPloter.AddLine(db, ptS.C2D((capW * 0.5 + 2 * scale), -foundL * 0.5 + refer_location + refer_body_distinct), p5.C2D(-bottomW), ref ext, "H细线");
                for (int i = 0; i < num; i++)
                {
                    double hh = 800;
                    if (i % 2 == 1)
                        hh = 400;
                    PLPloter.AddLine(db, ptLadderS.C2D(width * 0.5+ top_start_height).C2D((i + 1) * 125 ), ptLadderS.C2D(width * 0.5+ top_start_height).C2D((i + 1) * 125, -hh), ref ext, "H细线");
                    //PLPloter.AddLine(db, p5.C2D((i + 1) * 125+ bottomW), p5.C2D((i + 1) * 125+ bottomW, -hh), ref ext, "H细线");
                }

                List<Point2d> lst = new List<Point2d>();
                Point2d p1 = ptA.C2D(bAW * 0.5);
                Point2d p2 = ptA.C2D(capW * 0.5 + 2 * scale);
                Point2d p3 = p2.C2D(0,-bl);
                Point2d p4 = ptLadderS.C2D(width * 0.5 + top_start_height);
                Point2d p5 = ptLadderS.C2D(width * 0.5 + top_start_height, top_start_height);
                Point2d p6 = ptLadderS.C2D(-width * 0.5 , top_start_height);
                lst.Add(p1);
                lst.Add(p2);
                lst.Add(p3);
                lst.Add(p4);
                lst.Add(p5);
                lst.Add(p6);
                PLPloter.AddPolylineByPointListWhitHatch(db, lst, ref ext, "H细线", true, scale * 8, 135, "ANSI36");
                Point2d pp = ptLadderS.C2D(width * 0.5 + top_start_height * 0.5, -start_ladder_ear_length * 0.5);
                DimPloter.AddMultiMLeader(db, pp, pp.C2D(capW * 0.5-bAW*0.5-width+3*scale, - 3 * scale),  pp.C2D(capW * 0.5 - bAW * 0.5 - width + 3 * scale, -3 * scale), "检修步梯", ref ext, scale);
                DimPloter.DimRadius(db, ptA.C3D(capW * 0.5 + 4.01 * scale+25*scale,2*scale), ptA.C3D(capW * 0.5 + 4 * scale+25 * scale, 2 * scale), 10 * scale, ref ext, scale, "接入坡面排水系统");
                #endregion

            }
            //其它

            List<Point2d> ptABLLst = new List<Point2d>();
            List<Point2d> ptABRLst = new List<Point2d>();
            ptABLLst.Add(ptS.C2D(-(capW * 0.5 + 2 * scale), -foundL * 0.5 + refer_location + refer_body_distinct));
            ptABLLst.Add(ptS.C2D(-bAW*0.5, -foundL * 0.5 + refer_location + refer_body_distinct));
            ptABLLst.Add(ptS.C2D(-bAW * 0.5, -foundL * 0.5 + refer_location + refer_body_distinct+bl));
            ptABLLst.Add(ptS.C2D(-bw * 0.5+300, -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            ptABLLst.Add(ptTS.C2D(-bw * 0.5 + 900, 0));
            ptABLLst.Add(ptTS.C2D(-(capW * 0.5 + 2 * scale), 0));
            PLPloter.AddPolylineByPointListWhitHatch(db, ptABLLst, ref ext, "H细线", true, scale * 8, 135,"ANSI36");

            //ptABRLst.Add(ptS.C2D((capW * 0.5 + 2 * scale), -foundL * 0.5 + refer_location + refer_body_distinct));
            //ptABRLst.Add(ptS.C2D(bAW * 0.5, -foundL * 0.5 + refer_location + refer_body_distinct));
            ptABRLst.Add(ptS.C2D((capW * 0.5 + 2 * scale), -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            ptABRLst.Add(ptS.C2D(bAW * 0.5, -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            ptABRLst.Add(ptS.C2D(bw * 0.5 - 300, -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            ptABRLst.Add(ptTS.C2D(bw * 0.5 - 900, 0));
            ptABRLst.Add(ptTS.C2D((capW * 0.5 + 2 * scale), 0));
            PLPloter.AddPolylineByPointListWhitHatch(db, ptABRLst, ref ext, "H细线", true, scale * 8, 135, "ANSI36");

            ptABLLst = new List<Point2d>();
            ptABRLst = new List<Point2d>();
            double h = (ptTS.Y - ptA.Y)*(100/600.0);
            ptABLLst.Add(ptS.C2D(-bw * 0.5 + 600, -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            ptABLLst.Add(ptTS.C2D(-bw * 0.5 + 1100, -h));
            ptABLLst.Add(ptS.C2D(-bw * 0.5 + 1100, -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            PLPloter.AddPolylineByPointListWhitHatch(db, ptABLLst, ref ext, "H细线", true, scale * 8, 0, "ANSI31");

            ptABRLst.Add(ptS.C2D(bw * 0.5 - 600, -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            ptABRLst.Add(ptTS.C2D(bw * 0.5 - 1100, -h));
            ptABRLst.Add(ptS.C2D(bw * 0.5 - 1100, -foundL * 0.5 + refer_location + refer_body_distinct + bl));
            PLPloter.AddPolylineByPointListWhitHatch(db, ptABRLst, ref ext, "H细线", true, scale * 8, 0, "ANSI31");

            PLPloter.AddPloy4WithHatch(db, ptA.C2D(0,300),bw*0.5-1100+10, bw * 0.5 - 1100 + 10, 300, ref ext, "H细线",  "GRATE", scale * 15);

            RebarDimPloter.CreateLeadWireWithoutCircleMark(db, ref ext, ptA.C3D(scale * 2, 300), "集水沟", "", Extensions.curFont, scale, 3 * scale, 3 * scale);
            RebarDimPloter.CreateLeadWireWithoutCircleMark(db, ref ext, ptTS.C3D(-bw * 0.5 + 1050, -h-500), "坡面硬化", "15cm混凝土", Extensions.curFont, scale, 2 * scale, 2 * scale);
            RebarDimPloter.CreateLeadWireWithoutCircleMark(db, ref ext, ptTS.C3D(-bw * 0.5 + 1050, -h -500- scale*10), "1:1边坡", "", Extensions.curFont, scale, 2 * scale, 2 * scale);

        }


        public void RendeDetail(ref Database db, Point2d insertPoint, out Extents2d ext, double scale = 50)
        {
          
            ext = new Extents2d(insertPoint, insertPoint);
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -2 * scale);


            string text = @"注：
   1.本图尺寸均以毫米为单位。
   2.承台表面的采用直径16mm钢筋按照15cm间距布置，背墙和侧墙竖向钢筋要伸入台身不小于100cm。";
          
            TextPloter.AddMText(db, M1.C3D(), ref ext, text, scale, 3, 80 * scale, Extensions.curFont);

            try
            {
       
            }
            catch (Exception ex)
            {

            }
        }

        /// <summary>
        /// 绘制A截面
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="insertPoint"></param>
        /// <param name="scale"></param>
        public void PlotSectionA(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            Point2d CT = insertPoint;


            ext = new Extents2d(CT, CT);
            TextPloter.AddTitle(db, CT, ref ext, "A-A", "", scale);

            double maxH = 0;
            if (dtAbutmentBody.Rows.Count > 0)
            {
                maxH = double.Parse(dtAbutmentBody.Rows[0]["height"].ToString());
            }
            if (dtAbutmentBackWall.Rows.Count > 0)
            {
                maxH = maxH > double.Parse(dtAbutmentBackWall.Rows[0]["height"].ToString()) ? maxH : double.Parse(dtAbutmentBackWall.Rows[0]["height"].ToString());
            }
            if (dtAbutmentEarWall.Rows.Count > 0)
            {
                maxH = maxH > double.Parse(dtAbutmentEarWall.Rows[0]["height"].ToString()) ? maxH : double.Parse(dtAbutmentEarWall.Rows[0]["height"].ToString());
            }
            maxH = maxH * 1000;


            //台身、背墙
            double refer_location = double.Parse(dtAbutment.Rows[0]["refer_location"].ToString()) * 10;
            double refer_body_distinct = double.Parse(dtAbutment.Rows[0]["refer_body_distinct"].ToString()) * 10;
            double ibeam_cap_height = double.Parse(dtAbutment.Rows[0]["ibeam_cap_height"].ToString()) * 10;

            //基础
            Point2d pt = insertPoint.C2D(0, -30 * scale);
            double foundL = 0;
            Point2d ptS = insertPoint.C2D(0, -25 * scale);
            Point2d ptFS = ptS;
            Point2d ptTS = insertPoint.C2D(0, -5 * scale);
            Point2d ptA = ptTS;
            Point2d ptDimL = ptS;
            Point2d ptDimR = ptS;
            Point2d ptEnd = ptS;
            double capH = 0, hCap = 0, capW = 0, capL = 0, lCap = 0, capTW = 0, capTL = 0,capTotalH=0;
            int layer = 2;
            if (dtSpreadFoundation.Rows.Count > 0)
            {
                string section_type = dtSpreadFoundation.Rows[0]["section_type"].ToString();
                if (section_type == "1")//矩形扩基
                {
                    #region 矩形扩基
                    capW = double.Parse(dtSpreadFoundation.Rows[0]["width"].ToString()) * 10;
                    capL = double.Parse(dtSpreadFoundation.Rows[0]["length"].ToString()) * 10;
                    capH = double.Parse(dtSpreadFoundation.Rows[0]["height"].ToString()) * 10;
                    double wCap = double.Parse(dtSpreadFoundation.Rows[0]["width_cap"].ToString()) * 10;
                    lCap = double.Parse(dtSpreadFoundation.Rows[0]["length_cap"].ToString()) * 10;
                    hCap = double.Parse(dtSpreadFoundation.Rows[0]["height_cap"].ToString()) * 10;
                    layer = int.Parse(dtSpreadFoundation.Rows[0]["layer"].ToString());

                    ptS = pt.C2D(0, -maxH - capH - (layer - 1) * hCap);
                    PLPloter.AddScaleLine(db, pt.C2D(-refer_location, 2 * scale), ptS.C2D(-refer_location, -2 * scale), ref ext, "H中心线", 5);
                    DimPloter.AddMultiMLeader(db, pt.C2D(-refer_location, -2 * scale), pt.C2D(-refer_location+2*scale, 2 * scale), pt.C2D(-refer_location + 2 * scale, 2 * scale), "理论跨经线", ref ext, scale);

                    //PLPloter.AddPloy4WithHatch(db, ptS.C2D(0, capH), capL * 0.5, capL * 0.5, capH, ref ext, "H细线", "ANSI31", scale * 5);
                    PLPloter.AddPoly8WhitHatch(db, ptS.C2D(0, capH), ref ext, capH, capL, "H虚线", 100, capH, 0, 0, scale * 5,0, "ANSI31");
                    //ptDimL = ptS.C2D(-capW * 0.5 - 5 * scale);
                    ptDimR = ptS.C2D(capL * 0.5 + 5 * scale);
                    for (int i = 0; i < layer - 1; i++)
                    {
                        PLPloter.AddPloy4WithHatch(db, ptS.C2D(0, capH + (i + 1) * hCap), (capL - (i + 1) * lCap * 2) * 0.5, (capL - (i + 1) * lCap * 2) * 0.5, hCap, ref ext, "H粗线", "AR-CONC", 50);

                        DimPloter.DimAli(db, ptS.C3D(0, capH + (i + 1) * hCap), ptS.C3D(0, capH + (i + 1) * hCap - hCap), ptDimR.C3D(5 * scale), ref ext, scale);
                    }
                    DimPloter.DimAli(db, ptS.C3D(0, capH), ptS.C3D(), ptDimR.C3D(5 * scale), ref ext, scale);
                    ptFS = ptS.C2D(0, capH + (layer - 1) * hCap);
                    capTW = capW - (layer - 1) * wCap * 2;
                    capTL = capL - (layer - 1) * lCap * 2;

                    capTotalH = capH + (layer - 1) * hCap;
                    #endregion
                }
            }


            double bw = 0, bl = 0, bAW = 0, ibeamW = 0;

            if (dtAbutmentBody.Rows.Count > 0)
            {
                double bodyH = double.Parse(dtAbutmentBody.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentBody.Rows[0]["top_w"].ToString()) * 1000;
                double top_l = double.Parse(dtAbutmentBody.Rows[0]["top_l"].ToString()) * 1000;
                double ibeam_width = double.Parse(dtAbutmentBody.Rows[0]["ibeam_width"].ToString()) * 1000;
                ibeamW = ibeam_width;
                bw = top_w;
                bl = top_l;
            }
            if (dtAbutmentBody.Rows.Count <= 0 && dtAbutmentBackWall.Rows.Count > 0)
            {
                double bodyH = double.Parse(dtAbutmentBackWall.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentBackWall.Rows[0]["top_w"].ToString()) * 1000;
                double top_l = double.Parse(dtAbutmentBackWall.Rows[0]["top_l"].ToString()) * 1000;
                double ibeam_width = double.Parse(dtAbutmentBackWall.Rows[0]["ibeam_width"].ToString()) * 1000;
                ibeamW = ibeam_width;
                bw = top_w;
                bl += top_l;
            }
            double topEarL = 0;
            //耳墙
            if (dtAbutmentEarWall.Rows.Count > 0)
            {
                #region 桥台(台身+耳墙)
                double height = double.Parse(dtAbutmentEarWall.Rows[0]["height"].ToString()) * 1000;
                double top_w = double.Parse(dtAbutmentEarWall.Rows[0]["top_w"].ToString()) * 1000;
                double top_l = double.Parse(dtAbutmentEarWall.Rows[0]["top_l"].ToString()) * 1000;
                double start_change_height = double.Parse(dtAbutmentEarWall.Rows[0]["start_change_height"].ToString()) * 1000;
                double slope_l = double.Parse(dtAbutmentEarWall.Rows[0]["slope_l"].ToString());
                double slope_w = double.Parse(dtAbutmentEarWall.Rows[0]["slope_w"].ToString());
                ptA = ptFS.C2D(-refer_body_distinct - refer_location - bl, maxH);
                double bottomL = top_l + (height - start_change_height) * slope_l;
                double bottomW = top_w + (height) * slope_w;
                topEarL = top_l;
                bAW = bw + bottomW * 2;
                //PLPloter.AddPloy4WithHatch(db, ptA.C2D(bl * 0.5), bl * 0.5, bl * 0.5, maxH, ref ext, "H细线","ANSI31",scale*5);
                PLPloter.AddPloy4(db, ptA.C2D(bl * 0.5), bl * 0.5, bl * 0.5, maxH, ref ext, "H细线");


                DimPloter.DimAli(db, ptFS.C3D(-capTL * 0.5), ptFS.C3D(-capTL * 0.5 + bl), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-capTL * 0.5 + bl), ptFS.C3D(-refer_location - refer_body_distinct), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-refer_location - refer_body_distinct), ptFS.C3D(-refer_location), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-refer_location), ptFS.C3D(capTL * 0.5), ptFS.C3D(0, -5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptFS.C3D(-capTL * 0.5), ptFS.C3D(capTL * 0.5), ptFS.C3D(0, -8.5 * scale), ref ext, scale);

                DimPloter.DimAli(db, pt.C3D(-(refer_location + refer_body_distinct + bl)), pt.C3D(-(refer_location + refer_body_distinct + bl) + top_l), pt.C3D(0, 10 * scale), ref ext, scale);
                DimPloter.DimAli(db, pt.C3D(-(refer_location + refer_body_distinct + bl) + top_l), pt.C3D(-(refer_location + refer_body_distinct + bl) + bottomL), pt.C3D(0, 10 * scale), ref ext, scale);
                DimPloter.DimAli(db, pt.C3D(-(refer_location + refer_body_distinct + bl) + bottomL), pt.C3D(capTL * 0.5), pt.C3D(0, 10 * scale), ref ext, scale);
                DimPloter.DimAli(db, pt.C3D(-(refer_location + refer_body_distinct + bl)), pt.C3D(-refer_location), pt.C3D(0, 15 * scale), ref ext, scale);
                DimPloter.DimAli(db, pt.C3D(-refer_location), pt.C3D(capTL * 0.5), pt.C3D(0, 15 * scale), ref ext, scale);

                List<Point2d> ptLst = new List<Point2d>();
                Point2d p1 = ptA.C2D();
                Point2d p2 = ptA.C2D(top_l, 0);
                Point2d p3 = ptA.C2D(bottomL, -maxH + start_change_height);
                Point2d p4 = ptA.C2D(bottomL, -maxH);


                ptLst.Add(p1);
                ptLst.Add(p2);
                ptLst.Add(p3);
                ptLst.Add(p4);
                PLPloter.AddPolylineByPointList(db, ptLst, ref ext, "H细线", false);

                DimPloter.DimAli(db, p4.C3D(), p3.C3D(), p4.C3D(5 * scale), ref ext, scale);
                DimPloter.DimAli(db, p4.C3D(0, maxH), p3.C3D(), p4.C3D(5 * scale), ref ext, scale);

                DimPloter.DimAli(db, p4.C3D(0, maxH), p4.C3D(), p4.C3D(-15 * scale), ref ext, scale);
                #endregion
            }

            double cushionLength = 800;
            double cushionWidth = 800;
            double cushionHeight = 200;
            if (dtCushionStone.Rows.Count > 0)
            {
                #region 垫石
                cushionLength = double.Parse(dtCushionStone.Rows[0]["length"].ToString());
                cushionWidth = double.Parse(dtCushionStone.Rows[0]["width"].ToString());
                cushionHeight = double.Parse(dtCushionStone.Rows[0]["height"].ToString());

                PLPloter.AddPloy4(db, ptFS.C2D(-refer_location, cushionHeight), cushionLength * 0.5, cushionLength * 0.5, cushionHeight, ref ext, "H细线");

                string path = Extensions.curAppPath + "Aviation.dwg";
                string _blcName = "ZhiZuo";
                BlockPlot.InsertBlockByDwg(db, path, _blcName, "H细线", ptFS.C3D(-refer_location, cushionHeight), ref ext, 10, 0, true, false);
                #endregion
            }
            Point2d ptLS = ptA;
            double ladderH = 0;
            //爬梯
            if (dtAbutmentLadder.Rows.Count > 0)
            {
                #region 爬梯
                double divcap = double.Parse(dtAbutmentLadder.Rows[0]["divcap"].ToString()) * 10;
                double width = double.Parse(dtAbutmentLadder.Rows[0]["width"].ToString()) * 10;
                double height = double.Parse(dtAbutmentLadder.Rows[0]["height"].ToString()) * 1000;
                double bottom_start_height = double.Parse(dtAbutmentLadder.Rows[0]["bottom_start_height"].ToString()) * 10;
                double bottom_extend_length = double.Parse(dtAbutmentLadder.Rows[0]["bottom_extend_length"].ToString()) * 10;
                double top_start_height = double.Parse(dtAbutmentLadder.Rows[0]["top_start_height"].ToString()) * 10;
                double start_ladder_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_length"].ToString()) * 10;
                double start_ladder_ear_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_ear_length"].ToString()) * 10;
                ladderH = height;
                int numL = (int)((height - start_ladder_length) / divcap);
                Point2d ptLadderS = ptA.C2D(bl - top_start_height, -maxH + height);
                ptLS = ptA.C2D(0, -maxH + height);
                double ladderW = top_start_height + numL * divcap;
                PLPloter.AddLine(db, ptLadderS.C2D(top_start_height), ptA.C2D(topEarL + (maxH - height), -(maxH - height)), ref ext, "H虚线");
                List<Point2d> ptLst = new List<Point2d>();
                ptLst.Add(ptLadderS);
                ptLst.Add(ptLadderS.C2D(top_start_height));

                Point2d p0 = ptLadderS.C2D(top_start_height, -start_ladder_length);
                ptLst.Add(p0);
                p0 = p0.C2D(start_ladder_length);
                for (int i = 1; i <= numL; i++)
                {
                    ptLst.Add(p0.C2D(divcap * (i - 1), -divcap * (i - 1)));
                    ptLst.Add(p0.C2D(divcap * (i - 1), -divcap * i));
                }
                ptLst.Add(p0.C2D(divcap * (numL - 1) - bottom_start_height, -divcap * numL));
                p0 = p0.C2D(divcap * (numL - 1) - bottom_start_height, -divcap * numL);
                //ptLst.Add(p0);
                p0 = p0.C2D(0, height - divcap * (numL - 1) - start_ladder_length - top_start_height);
                ptLst.Add(p0);
                for (int i = 1; i < numL; i++)
                {
                    ptLst.Add(p0.C2D(-divcap * i, divcap * (i - 1)));
                    ptLst.Add(p0.C2D(-divcap * i, divcap * i));
                }
                ptLst.Add(ptLadderS.C2D(0, -start_ladder_length - top_start_height));
                PLPloter.AddPolylineByPointList(db, ptLst, ref ext, "H虚线", true);


                #endregion
            }



            double bridgeSlope = 0;
            double divCap = 3, divHeight = 3;
            if (dtAviationBridgeInfo.Rows.Count > 0)
            {
                bridgeSlope = double.Parse(dtAviationBridgeInfo.Rows[0]["bridge_slope"].ToString()) * 0.01;
                divCap = double.Parse(dtAviationBridgeInfo.Rows[0]["beam_section_width"].ToString()) * 1000;
                divHeight = double.Parse(dtAviationBridgeInfo.Rows[0]["beam_height"].ToString()) * 1000;
            }
            double hh = 0;
            Point2d ptAB = ptA;
            if (dtSection.Rows.Count > 0)
            {
                #region 主梁
                DataRow dr = dtSection.Rows[0];
                string straight_web_bar = dr["straight_web_bar"].ToString().Contains("HN") || dr["straight_web_bar"].ToString().Contains("HW") || dr["straight_web_bar"].ToString().Contains("HM") ? dr["straight_web_bar"].ToString() : "矩形管" + dr["straight_web_bar"].ToString();
                string diagonal_brace = dr["diagonal_brace"].ToString().Contains("HN") || dr["diagonal_brace"].ToString().Contains("HW") || dr["diagonal_brace"].ToString().Contains("HM") ? dr["diagonal_brace"].ToString() : "矩形管" + dr["diagonal_brace"].ToString();
                string[] sizeWebBar = straight_web_bar.Replace("矩形管", "").Replace("HN", "").Replace("HW", "").Split('*');//主管
                string[] sizeBrace = diagonal_brace.Replace("矩形管", "").Replace("HN", "").Replace("HW", "").Split('*');//斜腹杆
                                                                                                                      //常规段
                double w = double.Parse(sizeWebBar[1]);
                double h = double.Parse(sizeWebBar[0]);
                double wB = double.Parse(sizeBrace[1]);
                double hB = double.Parse(sizeBrace[0]);
                double ang = Math.Atan(bridgeSlope);
                Point2d ptIBeamS = ptFS.C2D(-refer_location, ibeam_cap_height);
                Point2d ptIBeamE = ptFS.C2D(capTL * 0.5, ibeam_cap_height - (refer_location + capTL * 0.5) * bridgeSlope);
                Point2d ptTopIBeamS = ptIBeamS.C2D(divHeight * Math.Sin(ang), divHeight * Math.Cos(ang));
                Point2d ptTopIBeamE = ptIBeamE.C2D(divHeight * Math.Sin(ang), divHeight * Math.Cos(ang));

                DimPloter.DimAli(db, ptIBeamS.C3D(), ptIBeamS.C3D(0, -ibeam_cap_height), ptIBeamS.C3D(cushionLength*0.5+5 * scale), ref ext, scale);

                List<Point2d> ptLst = new List<Point2d>();
                ptLst.Add(ptIBeamE);
                ptLst.Add(ptIBeamS);
                ptLst.Add(ptTopIBeamS);
                ptLst.Add(ptTopIBeamE);

                PLPloter.AddPolylineByPointList(db, ptLst, ref ext, "H虚线", false);

                Point2d ptIBeamS0 = ptIBeamS.C2D(-400, 400 * bridgeSlope);
                Point2d ptTopIBeamS0 = ptTopIBeamS.C2D(-400, 400 * bridgeSlope);

                Point2d p1 = ptIBeamS0.C2D(-h * 0.5 * Math.Sin(ang), -h * 0.5 * Math.Cos(ang));
                Point2d p2 = ptIBeamS0.C2D(h * 0.5 * Math.Sin(ang), h * 0.5 * Math.Cos(ang));
                Point2d p3 = ptIBeamE.C2D(h * 0.5 * Math.Sin(ang), h * 0.5 * Math.Cos(ang));
                Point2d p4 = ptIBeamE.C2D(-h * 0.5 * Math.Sin(ang), -h * 0.5 * Math.Cos(ang));

                List<Point2d> lst = new List<Point2d>();
                lst.Add(p4);
                lst.Add(p1);
                lst.Add(p2);
                lst.Add(p3);

                PLPloter.AddPolylineByPointList(db, lst, ref ext, "H虚线", false);



                Point2d pp1 = ptTopIBeamS0.C2D(-h * 0.5 * Math.Sin(ang), -h * 0.5 * Math.Cos(ang));
                Point2d pp2 = ptTopIBeamS0.C2D(h * 0.5 * Math.Sin(ang), h * 0.5 * Math.Cos(ang));
                Point2d pp3 = ptTopIBeamE.C2D(h * 0.5 * Math.Sin(ang), h * 0.5 * Math.Cos(ang));
                Point2d pp4 = ptTopIBeamE.C2D(-h * 0.5 * Math.Sin(ang), -h * 0.5 * Math.Cos(ang));

                lst = new List<Point2d>();
                lst.Add(pp4);
                lst.Add(pp1);
                lst.Add(pp2);
                lst.Add(pp3);

                PLPloter.AddPolylineByPointList(db, lst, ref ext, "H虚线", false);

                RebarPLPloter.CreateBreakLineV(db, ref ext, p4.C2D(0, -3 * scale), pp3.C2D(0, 3 * scale), scale);
                DimPloter.DimAli(db, p3.C3D(), p4.C3D(), p4.C3D(5 * scale), ref ext, scale);
                DimPloter.DimAli(db, pp3.C3D(), pp4.C3D(), pp4.C3D(5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptIBeamE.C3D(), ptTopIBeamE.C3D(), p4.C3D(10 * scale), ref ext, scale);

                Point2d p11 = ptTopIBeamS0.C2D((h * 0.5 - 100) * Math.Sin(ang), (h * 0.5 - 100) * Math.Cos(ang));
                Point2d p12 = ptTopIBeamS0.C2D((h * 0.5 - 50) * Math.Sin(ang), (h * 0.5 - 50) * Math.Cos(ang));
                Point2d p13 = ptTopIBeamE.C2D((h * 0.5 - 50) * Math.Sin(ang), (h * 0.5 - 50) * Math.Cos(ang));
                Point2d p14 = ptTopIBeamE.C2D((h * 0.5 - 100) * Math.Sin(ang), (h * 0.5 - 100) * Math.Cos(ang));

                lst = new List<Point2d>();
                lst.Add(p14);
                lst.Add(p11);
                lst.Add(p12);
                lst.Add(p13);

                PLPloter.AddPolylineByPointListWhitHatch(db, lst, ref ext, "H虚线", true, scale * 5, 0, "ANSI37");

                Point2d ptMid = GeTools.MidPoint(p12.C3D(), p14.C3D()).C2D();
                DimPloter.AddMultiMLeader(db, ptMid, ptMid.C2D( 2 * scale, 2 * scale), ptMid.C2D(2 * scale, 2 * scale), "桥面板", ref ext, scale);

                string path = Extensions.curAppPath + "Aviation.dwg";
                string _blcName = "TaB";
                BlockPlot.InsertBlockByDwg(db, path, _blcName, "H细线", p12.C3D(0), ref ext, 10, 0, true, false);
                hh = p12.Y - ptFS.Y - 58;
                ptAB = ptA.C2D(0, -maxH + hh);
                PLPloter.AddPloy4WithHatch(db, ptAB.C2D(bl * 0.5), bl * 0.5, bl * 0.5, hh, ref ext, "H细线", "AR-CONC", 50);


                lst = new List<Point2d>();
                lst.Add(ptLS);
                lst.Add(ptLS.C2D(bl));
                lst.Add(ptLS.C2D(bl + refer_body_distinct + refer_location + capTL * 0.5, -(refer_body_distinct + refer_location + capTL * 0.5)));


                PLPloter.AddPolylineByPointList(db, lst, ref ext, "H虚线", false);

                #endregion
            }
            List<Point2d> lstS0 = new List<Point2d>();
            List<Point2d> lstS = new List<Point2d>();
            lstS.Add(ptAB);
            lstS0.Add(ptAB);
            lstS.Add(ptAB.C2D(0, -315));
            lstS.Add(ptAB.C2D(-300, -315));
            lstS.Add(ptAB.C2D(-300, 30));
            lstS0.Add(ptAB.C2D(-300, 30));
            lstS.Add(ptAB);


            Polyline PL1 = PLPloter.GetPolylineByPointList(db, lstS, ref ext, "H细线", true);
            DimPloter.AddMultiMLeader(db, ptAB.C2D(-10, -20), ptA.C2D(2*scale, 3 * scale), ptA.C2D(2 * scale, 3 * scale), "大样1", ref ext, scale);
            PLPloter.AddCircle(db, ptAB.C2D(-300, 30), 600, ref ext);

            lstS = new List<Point2d>();
            lstS.Add(ptAB.C2D(-50,-50+5));
            lstS.Add(ptAB.C2D(-50, -265));
            lstS.Add(ptAB.C2D(-250, -265));
            lstS.Add(ptAB.C2D(-250, -50+25));
            lstS0.Add(ptAB.C2D(-310, -50+31));
            lstS.Add(ptAB.C2D(-50, -50 + 5));
            lstS0.Add(ptAB.C2D(0, -50));


            Polyline PL2 = PLPloter.GetPolylineByPointList(db, lstS, ref ext, "H细线", true);
            PLPloter.AddPolylineByPointList(db, lstS0, ref ext, "H细线", true);
            HatchPloter.HatchEnity(db, "ANSI31", scale*4, 0, PL1.ObjectId, PL2.ObjectId);

           

            PLPloter.AddPloy4(db, ptAB.C2D(-150,115),150,150,430, ref ext, "H细线");
            PLPloter.AddPloy4(db, ptAB.C2D(-150, 65), 100, 100, 330, ref ext, "H细线");
            PLPloter.AddLine(db, ptAB, ptAB.C2D(-300 - 5080, 30 + 508), ref ext, "H细线");
            PLPloter.AddLine(db, ptAB, ptAB.C2D(-300 - 5080, 30 + 508), ref ext, "H细线");
            PLPloter.AddLine(db, ptLS.C2D(bl), ptAB.C2D(-300 - 5080, 30 + 508), ref ext, "H细线");
            Point2d ptR1 = ptAB.C2D(-300 - 5080, 30 + 508);
            PLPloter.AddLine(db, ptR1, ptR1.C2D(-300-800), ref ext, "H细线");
            double R = 166.888;
            double startA = 25;
            double endA = 155;
            Point2d ptCen = ptR1.C2D(R * Math.Cos(GeTools.DegreeToRadian(endA)), -R * Math.Sin(GeTools.DegreeToRadian(endA)));
            Arc arc= PLPloter.AddAreWithHatch(db, ptCen, ref ext, "H细线",30,R, startA, endA);
            double hE = Math.Sqrt(Math.Pow(150,2)+ Math.Pow(15, 2));
            DimPloter.DimAli(db, arc.EndPoint.C3D(), arc.StartPoint.C3D(), ptR1.C3D(0, 5 * scale), ref ext, scale,"300");
            DimPloter.DimAli(db, arc.EndPoint.C3D(150), ptCen.C3D(0,R), ptR1.C3D(-300-5*scale, 5 * scale), ref ext, scale, "100");

            Point2d ptR2 = ptAB.C2D(-300, 30-hE);
            Point2d ptR21 = ptR2.C2D(-5100, 510);

            PLPloter.AddLine(db, ptR2, ptR21.C2D(), ref ext, "H细线");

            lstS = new List<Point2d>();
            //lstS.Add(ptR1.C2D());
            lstS.Add(ptR2.C2D());
            lstS.Add(ptR21.C2D());
           

            lstS.Add(arc.EndPoint.C2D(0,-hE));
            lstS.Add(arc.EndPoint.C2D());
            lstS.Add(ptR1.C2D());
            lstS.Add(ptAB.C2D(-300, 30));
            PLPloter.AddPolylineByPointListWhitHatch(db, lstS, ref ext, "H细线", true, 30, 0, "AR-CONC");

            double angS = Math.Atan(0.1);
            DimPloter.DimAli(db, ptR1.C3D(), ptAB.C3D(-300, 30), ptR1.C3D(0,5 * scale), ref ext, scale);
            DimPloter.DimAli(db, ptAB.C3D(-300, 30), ptAB.C3D(-300, 30).C3D(-150*Math.Sin(angS),-150*Math.Cos(angS)), ptR1.C3D(4000, 5 * scale), ref ext, scale,"150");


            lstS = new List<Point2d>();
            lstS.Add(ptAB.C2D(0, -315));
            lstS.Add(ptAB.C2D(-300, -315));
            lstS.Add(ptR2.C2D());
            lstS.Add(ptR21.C2D());
            lstS.Add(arc.EndPoint.C2D(0, -hE));
            lstS.Add(arc.EndPoint.C2D());
            lstS.Add(ptR1.C2D(-300 - 800));

            lstS.Add(ptR1.C2D(-300 - 800,-maxH- capTotalH-800));
            Point2d ptRBT = ptLS.C2D(bl + refer_body_distinct + refer_location + capTL * 0.5, -(refer_body_distinct + refer_location + capTL * 0.5));
            Point2d ptRB = ptLS.C2D(bl + ladderH+capTotalH+800, -(ladderH + capTotalH + 800));

            lstS.Add(ptRB);
            lstS.Add(ptRBT);
            lstS.Add(ptFS.C2D(capTL * 0.5, -capTotalH + capH));
            lstS.Add(ptFS.C2D(capL*0.5-100,-capTotalH+capH));
            lstS.Add(ptFS.C2D(capL * 0.5, -capTotalH));
            lstS.Add(ptFS.C2D(-capL * 0.5, -capTotalH));
            lstS.Add(ptFS.C2D(-capL * 0.5+100, -capTotalH + capH));
            lstS.Add(ptFS.C2D(-capTL * 0.5, -capTotalH + capH));
            lstS.Add(ptFS.C2D(-capTL * 0.5,0));
            lstS.Add(ptFS.C2D(-refer_location-refer_body_distinct-bl, 0));
            PLPloter.AddPolylineByPointListWhitHatch(db, lstS, ref ext, "H细线", true, scale*5, 135, "ANSI36");

            RebarPLPloter.CreateBreakLineV(db, ref ext, ptR1.C2D(-300 - 800), ptR1.C2D(-300 - 800, -maxH - capTotalH - 800), scale);

            RebarPLPloter.CreateBreakLineP(db, ref ext, ptR1.C2D(-300 - 800, -maxH - capTotalH - 800), ptRB, scale);
        }


        /// <summary>
        /// 绘制爬梯B截面
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="insertPoint"></param>
        /// <param name="scale"></param>
        public void PlotSectionB(ref Database db, ref Extents2d ext, Point2d insertPoint, int scale)
        {
            Point2d CT = insertPoint;

            TextPloter.AddTitle(db, CT, ref ext, "B-B", "", scale);
            double start_change_height = 0;

            if (dtAbutmentEarWall.Rows.Count > 0)
            {
                start_change_height = double.Parse(dtAbutmentEarWall.Rows[0]["start_change_height"].ToString()) * 1000;
            }
           
                //爬梯
                //爬梯
            if (dtAbutmentLadder.Rows.Count > 0)
            {
                #region 爬梯
                double divcap = double.Parse(dtAbutmentLadder.Rows[0]["divcap"].ToString()) * 10;
                double width = double.Parse(dtAbutmentLadder.Rows[0]["width"].ToString()) * 10;
                double height = double.Parse(dtAbutmentLadder.Rows[0]["height"].ToString()) * 1000;
                double bottom_start_height = double.Parse(dtAbutmentLadder.Rows[0]["bottom_start_height"].ToString()) * 10;
                double bottom_extend_length = double.Parse(dtAbutmentLadder.Rows[0]["bottom_extend_length"].ToString()) * 10;
                double top_start_height = double.Parse(dtAbutmentLadder.Rows[0]["top_start_height"].ToString()) * 10;
                double start_ladder_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_length"].ToString()) * 10;
                double start_ladder_ear_length = double.Parse(dtAbutmentLadder.Rows[0]["start_ladder_ear_length"].ToString()) * 10;

                int numL = (int)((height - start_ladder_length) / divcap);
                Point2d ptLadderS = insertPoint.C2D(-height * 0.5, -10 * scale);
                double ladderW = top_start_height + start_ladder_length + (numL - 1) * divcap + bottom_start_height + start_ladder_ear_length;
                Point2d ptDimL = insertPoint.C2D(-ladderW * 0.5 - 5 * scale);
                Point2d ptDimR = insertPoint.C2D(ladderW * 0.5 + 5 * scale);
                List<Point2d> ptLst = new List<Point2d>();
                ptLst.Add(ptLadderS);
                ptLst.Add(ptLadderS.C2D(top_start_height));

                Point2d p0 = ptLadderS.C2D(top_start_height, -start_ladder_length);
                ptLst.Add(p0);
                p0 = p0.C2D(start_ladder_length);

                DimPloter.DimAli(db, ptLadderS.C3D(), ptLadderS.C3D(top_start_height), ptLadderS.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptLadderS.C3D(top_start_height), ptLadderS.C3D(top_start_height + start_ladder_ear_length), ptLadderS.C3D(0, 5 * scale), ref ext, scale);
                DimPloter.DimAli(db, ptLadderS.C3D(top_start_height + start_ladder_ear_length), ptLadderS.C3D(ladderW), ptLadderS.C3D(0, 5 * scale), ref ext, scale);
                for (int i = 1; i <= numL; i++)
                {
                    ptLst.Add(p0.C2D(divcap * (i - 1), -divcap * (i - 1)));
                    ptLst.Add(p0.C2D(divcap * (i - 1), -divcap * i));
                }
                ptLst.Add(p0.C2D(divcap * (numL - 1) - bottom_start_height, -divcap * numL));
                p0 = p0.C2D(divcap * (numL - 1) - bottom_start_height, -divcap * numL);
                //ptLst.Add(p0);
                p0 = p0.C2D(0, height - divcap * (numL - 1) - start_ladder_length - top_start_height);
                ptLst.Add(p0);
                for (int i = 1; i < numL; i++)
                {
                    ptLst.Add(p0.C2D(-divcap * i, divcap * (i - 1)));
                    ptLst.Add(p0.C2D(-divcap * i, divcap * i));


                }
                ptLst.Add(ptLadderS.C2D(0, -start_ladder_length - top_start_height));
                PLPloter.AddPolylineByPointListWhitHatch(db, ptLst, ref ext, "H细线", true, 50, 0, "AR-CONC");


                ptLst = new List<Point2d>();
                Point2d p1 = ptLadderS.C2D();
                Point2d p2 = ptLadderS.C2D(start_ladder_ear_length, 0);
                Point2d p3 = ptLadderS.C2D(start_ladder_length + divcap * (numL - 1) + bottom_start_height + start_ladder_ear_length, -(divcap * (numL - 1) + start_ladder_length));
                Point2d p4 = ptLadderS.C2D(start_ladder_length + divcap * (numL - 1) + bottom_start_height + start_ladder_ear_length, -height);
                Point2d p5 = ptLadderS.C2D(top_start_height + start_ladder_length + divcap * (numL - 1), -height);

                ptLst.Add(p1);
                ptLst.Add(p2);
                ptLst.Add(p3);
                ptLst.Add(p4);
                ptLst.Add(p5);
                PLPloter.AddPolylineByPointList(db, ptLst, ref ext, "H细线", false);

                DimPloter.DimRot(db, ptLadderS.C3D(top_start_height + start_ladder_ear_length), p3.C3D(), ptDimR.C3D(), ref ext, 90, scale, "");
                DimPloter.DimRot(db, p3.C3D(), p4.C3D(), ptDimR.C3D(), ref ext, 90, scale, "");

                DimPloter.DimAli(db, ptLadderS.C3D(0, -start_ladder_length - top_start_height), ptLadderS.C3D(), ptDimL.C3D(), ref ext, scale);
                Point3d ptLS = ptLadderS.C3D(0, -start_ladder_length - top_start_height);
                for (int i = 1; i <= numL; i++)
                {
                    DimPloter.DimAli(db, ptLS.C3D(0, -(i - 1) * divcap), ptLS.C3D(0, -i * divcap), ptDimL.C3D(), ref ext, scale);
                }

                DimPloter.DimRot(db, ptLS.C3D(), ptLS.C3D(start_ladder_length), ptLadderS.C3D(0, -height - 5 * scale), ref ext, 0, scale);
                for (int i = 1; i < numL; i++)
                {
                    DimPloter.DimRot(db, ptLS.C3D(start_ladder_length + (i - 1) * divcap), ptLS.C3D(start_ladder_length + (i) * divcap), ptLadderS.C3D(0, -height - 5 * scale), ref ext, 0, scale, "");
                }
                DimPloter.DimRot(db, ptLS.C3D(), ptLS.C3D(start_ladder_length), ptLadderS.C3D(0, -height - 5 * scale), ref ext, 0, scale, "");
                DimPloter.DimRot(db, p5.C3D(), ptLS.C3D(start_ladder_length + (numL - 1) * divcap), ptLadderS.C3D(0, -height - 5 * scale), ref ext, 0, scale, "");
                DimPloter.DimRot(db, p5.C3D(), p4.C3D(), ptLadderS.C3D(0, -height - 5 * scale), ref ext, 0, scale, "");
                #endregion
            }
           
        }

        public void PlotSampleDetail(ref Database db, Point2d insertPoint, out Extents2d ext, double scale = 50)
        {

            ext = new Extents2d(insertPoint, insertPoint);
            Point2d CT = insertPoint;
            Point2d M1 = CT.C2D(0, -2 * scale);

            double bridgeSlope = 0;
            if (dtAviationBridgeInfo.Rows.Count > 0)
            {
                bridgeSlope = double.Parse(dtAviationBridgeInfo.Rows[0]["bridge_slope"].ToString()) ;
            }
            TextPloter.AddTitle(db, CT, ref ext, "大样1", "", scale);
            string path = Extensions.curAppPath + "Aviation.dwg";
            string _blcName = "shape1";
            BlockPlot.InsertBlockByDwg(db, path, _blcName, "H细线", M1.C3D(0), ref ext, scale, 0, true, false);
          


            _blcName = "TaBan";
            Point2d ptT = M1.C2D(0, -ext.L() - 2 * scale);
            BlockPlot.InsertBlockByDwg(db, path, _blcName, "H细线", ptT.C3D(), ref ext, scale*0.5, 0, true, false);
       
            TextPloter.AddDBText(db, ptT.C3D(48* scale * 0.5, -36.8* scale * 0.5),ref ext, bridgeSlope+"%", scale);

            string text = @"注：
   1.本图尺寸均以毫米为单位。
   2.承台表面的采用直径16mm钢筋按照15cm间距布置，背墙和侧墙竖向钢筋要伸入台身不小于100cm。";

            TextPloter.AddMText(db, M1.C3D(-ext.W()*0.5, -ext.L()-5*scale), ref ext, text, scale, 3, 80 * scale, Extensions.curFont);

            try
            {

            }
            catch (Exception ex)
            {

            }
        }

        /// <summary>
        /// 绘制大样和说明
        /// </summary>
        /// <param name="db"></param>
        /// <param name="ext"></param>
        /// <param name="insertPoint"></param>
        /// <param name="scale"></param>
        public void CalcultQuantity(ref Database db, out Extents2d ext, Point2d insertPoint, int scale)
        {
            Point2d CT = insertPoint;


            ext = new Extents2d(CT, CT);

            TextPloter.AddTitle(db, CT, ref ext, "大样1", "", scale);
            //爬梯


        }
        #endregion

    }
}
